<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 

<form:form method="post" action="doPreview.do" commandName="formData">
 
<table width="800px" class="form">
	<tbody>
    <tr>
        <td width="15%">
			統計年數
        </td>    
        <td width="35%">
        	自
        	<select name="startYear"> 
        		  <c:set var="defEndYear" value="${formData.defStartYear + 2}"/>
	        	  <c:forEach var="yy" begin="${formData.defStartYear }" end="${defEndYear }" step="1">

					  	<c:choose>
					  	  <c:when test="${(formData.startYear==null && yy==formData.defStartYear) || yy==formData.startYear}">
					      	<option value="${yy }" selected>${yy }</option>
					      </c:when>			
					      <c:otherwise>
					      	<option value="${yy }" >${yy }</option>
					      </c:otherwise>
					    </c:choose>

				  </c:forEach>
			</select>年至
			<select name="endYear"> 
        		  <c:set var="defEndYear" value="${formData.defStartYear + 2}"/>
	        	  <c:forEach var="yy" begin="${formData.defStartYear }" end="${defEndYear }" step="1">

					  	<c:choose>
					  	  <c:when test="${(formData.endYear==null && yy==defEndYear) || yy==formData.endYear}">
					      	<option value="${yy }" selected>${yy }</option>
					      </c:when>			
					      <c:otherwise>
					      	<option value="${yy }" >${yy }</option>
					      </c:otherwise>
					    </c:choose>

				  </c:forEach>
			</select>年
        </td>
        <td width="15%">
			統計時間類別
        </td>    
        <td width="35%">
 
				<c:choose>
					<c:when test="${formData.timeType!=null && formData.timeType=='Year'}">
			            <input type="radio" name="timeType" value="Year"  checked/> <spring:message code="report.timetype.year"/><br />
						<input type="radio" name="timeType" value="Season"/> <spring:message code="report.timetype.season"/><br />
						<input type="radio" name="timeType" value="Month"/> <spring:message code="report.timetype.month"/>
					</c:when>		
					<c:when test="${formData.timeType!=null && formData.timeType=='Season'}">
			            <input type="radio" name="timeType" value="Year" /> <spring:message code="report.timetype.year"/><br />
						<input type="radio" name="timeType" value="Season" checked/> <spring:message code="report.timetype.season"/><br />
						<input type="radio" name="timeType" value="Month"/> <spring:message code="report.timetype.month"/>
					</c:when>							
					<c:otherwise>
			            <input type="radio" name="timeType" value="Year" /> <spring:message code="report.timetype.year"/><br />
						<input type="radio" name="timeType" value="Season" /> <spring:message code="report.timetype.season"/><br />
						<input type="radio" name="timeType" value="Month" checked/> <spring:message code="report.timetype.month"/>
					</c:otherwise>
				</c:choose>  	        	
	                     
        </td>            
    </tr>

    </tbody>
    <tfoot>
    <tr>
        <td colspan="4">
        	<input type="hidden" name="defStartYear" value="${formData.defStartYear }"/>
        	<input type="hidden" name="reportType" value="${formData.reportType }"/>
            <input type="submit" value="查詢"/>
        </td>
    </tr> 
    </tfoot>       
</table> 
</form:form>
